Skip to content

feat: notifications#13

Merged
leobrqz merged 3 commits intomainfrom
feat/notifications
Mar 17, 2026
Merged

feat: notifications#13
leobrqz merged 3 commits intomainfrom
feat/notifications

Conversation

@leobrqz
Copy link
Owner

@leobrqz leobrqz commented Mar 17, 2026

Adds system notifications for scheduler events: toasts appear in the bottom-right of the screen when a scheduled run starts, finishes (exited/killed), or errors. Notifications can be turned on or off from the toolbar and follow the app theme.

Changes

Config

  • New option scheduler_notification_enabled in config.json with load_scheduler_notification_enabled() / save_scheduler_notification_enabled() in config.py.

New module: src/notifications.py

  • show_notification(event_type, schedule_name, script_name, rule_type, next_run, palette, error_message=None) – shows a toast with preformatted strings (no schedule dicts or scheduler engine).
  • update_notification_theme(palette) – updates the current toast when the user switches theme.
  • Queue – multiple events show toasts one after another (4s each or until closed).
  • Toast UI – rectangular window, object name notificationToast, bottom-right placement, topmost, 4s auto-close, close button with drawn X icon and "Close notification" tooltip. Styled via existing palette in theme.py.

GUI (gui.py)

  • Top bar – New Notification button (Project | Terminal | Venv | Notification | Theme) with dropdown Scheduled: On / Off that toggles and persists the flag.
  • Helpers_format_next_run_for_notification() (time: on HH:MM dd/mm/yy, interval: in Xh Ym or seconds when < 1 min), _build_notification_payload() (uses format_rule_display() for rule text), _get_schedule_and_history_for_id() to resolve schedule from history.
  • Trigger points (only when notifications are enabled):
    • Scheduled run start (after successful start in _execute_scheduled_run).
    • Scheduled run error (validate_trigger failure and exception in run_script_in_gitbash_captured).
    • Scheduled run exited (check_processes when process exits).
    • Scheduled run killed (manual Kill in _kill_script_row and when scheduler kills before next run in _execute_scheduled_run).
  • Theme_toggle_theme() calls update_notification_theme(self._palette) so toasts follow light/dark.

Theme (theme.py)

  • QSS for #notificationToast, #notificationTitle, #notificationBody, #notificationError, and #notificationCloseBtn (red border/icon, hover state) using existing palette keys.

Behavior

  • Scope: Only scheduler-triggered runs produce notifications; manual runs from Home do not.
  • Content: Each toast shows schedule name, script name, rule (e.g. "Interval: 1min"), and next run (with seconds when under 1 minute). Error toasts include the error message.
  • Dependencies: gui.pynotifications; notifications receive only strings and palette, no scheduler_engine or schedule dicts.

leobrqz added 3 commits March 16, 2026 23:48
Introduce scheduler system notifications:

- Add a new notifications.py module that implements queued, styled toast windows for scheduler events (start, finished_exited, finished_killed, error)
- Integrate notifications into the GUI by adding a Notification button with an on/off toggle, building notification payloads, and emitting toasts at schedule start/finish/kill/error points
- Persist the scheduler_notification_enabled flag via new load/save functions in config.py
- Add QSS styles for notification widgets and ensure theme updates propagate to visible notifications
- Replace textual close button with a styled icon button (drawn QIcon) and add hover tooltip/hover-state via an event filter; adjust notification layout margins and spacing.
- Update stylesheet for notification close button (border, sizing, hover/pressed colors).
- Show seconds in next-run formatting (return "in 0s" and "in Ns" for <60s) and use format_rule_display for schedule rule labels in the GUI. Also change trash SVG stroke to red.
@leobrqz leobrqz self-assigned this Mar 17, 2026
@leobrqz leobrqz linked an issue Mar 17, 2026 that may be closed by this pull request
@github-project-automation github-project-automation bot moved this to Backlog in ShScriptHub Mar 17, 2026
@leobrqz leobrqz moved this from Backlog to In progress in ShScriptHub Mar 17, 2026
@leobrqz leobrqz moved this from In progress to Done in ShScriptHub Mar 17, 2026
@leobrqz leobrqz merged commit 6e213f1 into main Mar 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Feat: Notifications

1 participant